{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "92f5ec54",
   "metadata": {},
   "source": [
    "## Creating a Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "06e8f3f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f94e0c4d",
   "metadata": {},
   "source": [
    "### Empty Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6159522c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Series([], dtype: float64)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-2-ef047fdb75c6>:1: DeprecationWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.\n",
      "  a=pd.Series()\n"
     ]
    }
   ],
   "source": [
    "a=pd.Series()\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf353326",
   "metadata": {},
   "source": [
    "### From List"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "522a6c18",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    A\n",
      "1    B\n",
      "2    C\n",
      "dtype: object\n",
      "0    A\n",
      "1    B\n",
      "2    C\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "list1=['A','B','C']\n",
    "print(pd.Series(list1))\n",
    "\n",
    "# or\n",
    "\n",
    "print(pd.Series(['A','B','C']))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2c21024",
   "metadata": {},
   "source": [
    "#### Custom indexes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "cd0e32d0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "First     A\n",
      "Second    B\n",
      "Third     C\n",
      "Fourth    D\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "a=pd.Series(['A','B','C','D'],index=['First','Second','Third','Fourth'])\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d8cdb619",
   "metadata": {},
   "source": [
    "### From numpy array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "3e1b2dab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    S\n",
      "1    A\n",
      "2    H\n",
      "3    I\n",
      "4    L\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "# simple array\n",
    "data = np.array(['S','A','H','I','L'])\n",
    "a = pd.Series(data)\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "73b1a8d6",
   "metadata": {},
   "source": [
    "### From dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "4ba266f6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0     Sahil\n",
      "1     Sonia\n",
      "2    Sourav\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "b=pd.Series({\n",
    "    0:'Sahil',\n",
    "    1:'Sonia',\n",
    "    2:'Sourav'\n",
    "})\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7d6a030",
   "metadata": {},
   "source": [
    "### Assigning indexes after declaring the series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "01a649d0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a     Sahil\n",
      "b     Sonia\n",
      "c    Sourav\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "new_indexes=['a','b','c']\n",
    "b.index=new_indexes\n",
    "print(b)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}